/*
   编写Base类使下列代码输出为1

   int i=2;
   int j=7;

   Base x(i);
   Base y(j);
   cout << (x+y == j - i) << endl;*/
#include <iostream>
using std::cout;
using std::endl;
using std::ostream;
class Base{
private:
    int m_val;
public:
    Base(int val = 0) 
        :m_val(val)
    {}
    //<<友元
    friend
        ostream & operator<<(ostream & os, const Base & rhs);
    //==
    friend
        bool operator==(const Base & lsh, const int & rhs);
    //+
    friend
        Base operator+(const Base & lhs, const Base & rhs);

};//end of class Base

//<<
ostream & operator<<(ostream & os, const Base & rhs) {
    os << rhs.m_val;
    return os;
}
//==
bool operator==(const Base & lsh, const int  & rhs) {
    return lsh.m_val == rhs;
}
//+
Base operator+(const Base & lhs, const Base & rhs) {
    return Base(rhs.m_val - lhs.m_val);
}

int main()
{
    int i=2;
    int j=7;

    Base x(i);
    Base y(j);
    cout << (x+y == j - i) << endl;

    return 0;
}

